

//
//  NQiuzhiMsgViewController.m
//  nncloud
//
//  Created by macfai on 2018/11/23.
//  Copyright © 2018 macfai. All rights reserved.
#import "NTalentSearchViewController.h"
#import "NSerchZhiweiViewController.h"
#import "NQiuzhiMsgViewController.h"
#import "NZhaopinCell.h"
#import "NQIyeRecruitDetailVC.h"
#import "NQiuzhiInfoDetailVC.h"
#import "NQiuzhiModel.h"
@interface NQiuzhiMsgViewController ()<UITableViewDataSource,UITableViewDelegate,STPickerSingleDelegate>

@property(nonatomic,strong)UITableView *tableView;

@property(nonatomic,strong)NSMutableArray *dataArray;


@end

@implementation NQiuzhiMsgViewController
#define cellIdentifier @"zhaopin"
#define SectionHeaderHeight  10.f

-(UITableView *)tableView{
    
    if (!_tableView) {
        
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 115.f;
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"NZhaopinCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
        _tableView.showsVerticalScrollIndicator = NO;
        //        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}
- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    self.dataArray = [NSMutableArray array];
    [self.navigationItem setItemWithTitle:@"求职信息" textColor:kNavigationTitleColor fontSize:18 itemType:center];
    [self addNavgationRightButtonWithFrame:CGRectMake(0, 0, 40, 40) title:@"" Image:@"搜索" selectedIMG:nil tartget:self action:@selector(search)];
    [self.view addSubview:self.tableView];
    [self loadData];
    // Do any additional setup after loading the view.
}

- (void)search{
    
    NTalentSearchViewController *search = [NTalentSearchViewController new];
    [self.navigationController pushViewController:search animated:YES];
    
}

- (void)loadData{
    //后期逐渐添加参数目前不需要参数
    [[NNRCNetRequest manager]getWithUrl:kQiuzhiListUrl params:nil success:^(id result) {
        YYLog(@"%@",result);
        WeakStament(ws);
        if ([[result objectForKey:@"code"] integerValue] == 0) {

            NSArray *arr = result[@"page"][@"records"];
            YYLog(@"%@",arr);
            for (NSDictionary *dict in arr) {
                NQiuzhiModel *model = [NQiuzhiModel mj_objectWithKeyValues:[dict deleteNull]];
                [ws.dataArray addObject:model];
            }
            [ws.tableView reloadData];

        }else{
            [AFToast showText:result[@"msg"]];
        }
        
    } failure:^(id failure) {
        
    }];
}

#pragma mark - delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NQiuzhiModel *model = self.dataArray[indexPath.section];
    NQiuzhiInfoDetailVC *detail = [NQiuzhiInfoDetailVC new];
    if (model.resumeUserId) {
        detail.qiuzhiId = model.resumeUserId;
    }
    [self.navigationController pushViewController:detail animated:YES];
}

#pragma mark - datasource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
     return  self.dataArray.count;
//    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NQiuzhiModel *model = self.dataArray[indexPath.section];
    NZhaopinCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    cell.name.font = [UIFont boldSystemFontOfSize:15];
    cell.otherLabel.hidden = false;
    cell.model = model;
    return cell;
}





#pragma mark - section head
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return SectionHeaderHeight;//如果设置section的header高度，不设置footer高度，footer默认等于header高度
}



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, SectionHeaderHeight)];
    view.backgroundColor = kBackgroundColor;
    return view;
}

#pragma mark - section foot
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}


@end
